/**
 * 格式化投票数
 */
export function formatVoteNum(num){
    num = +num;
    return num > 99999 ? '10w+':(num > 9999 ? (num/10000).toFixed(2)+'w' : num);
}

/**
 * 获取地址栏参数
 */
export function getParams(){
    let URLParams = new Object();
    let paramsStr = location.href.split('?')[1];
    if(paramsStr){
        let paramsArr = paramsStr.split('&');
        paramsArr.forEach((param)=>{
            let aParam = param.split('=')
            URLParams[aParam[0]] = aParam[1]
        });
    }
    return URLParams;
}

/**
 * 判断是不是手机号
 */
export function isTel(phone){
    return !!phone.match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[3678]|18[0-9]|14[57])[0-9]{8}$/)
}

/**
 * 判断是不是苹果
 */
export function isIOS(){
    var u = window.navigator.userAgent;
    return !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
}

/**
 * 判断是不是安卓
 */
 export function isAndroid(){
    var u = window.navigator.userAgent;
    return u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
 }

 /**
  * 判断是不是微信浏览器
  */
 export function isWeixin(){
     var u = navigator.userAgent.toLowerCase();
     return u.match(/MicroMessenger/i) == "micromessenger" || u.match(/WeiBo/i) == "weibo" || u.match(/AliApp/i) == "aliapp";
 }